package cn.honor.test;

import java.util.*;

/**
 * Created by 31464 on 2021/10/17.
 */
public class Example1 {
    private static final int[] a={5041,5761,4691,672,5172 ,-9735,-9907 ,-4906,2880 ,9222};
    private static final int[] b={3740,3871,3171,1886,163,1961 ,-4476,-7229 ,-9735,-11219};
    public static void main(String[] args) {
        List<Integer> resultList=new ArrayList<>();
        int loopLen=0;
        if(a.length>b.length){
            loopLen=a.length;
        }else{
            loopLen=b.length;
        }
        for(int i=0;i<loopLen;i++){
            Integer aTmp = getArrayValue(a,i);
            Integer bTmp = getArrayValue(b,i);
            resultList.add(aTmp+bTmp);
        }
        sortList(resultList);
        resultList.stream().forEach(x-> System.out.print(x+" "));
    }

    private static Integer getArrayValue(int[] tmpArr,int index) {
        try {
            return Math.abs(tmpArr[index]);
        }catch (Exception e){
            return 0;
        }
    }
    private static void sortList(List<Integer> aList) {
        Collections.sort(aList, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int i = o1 - o2;
                if(i>0){
                    return -1;
                }else if(i<0){
                    return 1;
                }else{
                    return 0;
                }
            }
        });

    }

}
